/*
    Project:        Home Power Control
    File:           HPCLight.h
    Author:         christian@karunamusic.at
    Date:           12.2014
    Description:    Sensor to measure the ambient light with the TSL45315.
 */

#ifndef HPCLIGHT_H
#define HPCLIGHT_H

#include "HPCThreadedSensor.h"


/** \brief The TSL45315 gets the data via I2C (device /dev/i2c-1, addr 0x29).
 * The pin from sensors is used here to store the i2c-address.
 */
class HPCLight: public HPCThreadedSensor
{
public:
    /** \brief Constructor
     *
     * \param id database id of the sensor.
     * \param i2caddr the address on the i2c-bus.
     * \param interval time (in seconds) to pause between querying the sensor.
     *
     */
    HPCLight( unsigned long id, unsigned int i2caddr, unsigned int interval );
    /** \brief Destructor.
     */
    virtual ~HPCLight();

    /** \brief Get the type of the sensor.
     *
     * \return SensorType Type of the sensor (from enum SensorType).
     *
     */
    virtual inline SensorType Type() const
      { return SensorType::HPCLight; }

protected:
    /** \brief Get a value from the sensor.
     */
    virtual void Measure();

    /** \brief Check if sensor has changed (called after interval pause).
     *
     * \return True if changed.
     */
    virtual bool hasChanged();

private:
    int m_I2C; /**< filehandle for i2c-device */
};

#endif // HPCLIGHT_H
